package online.abor;

import org.omg.CORBA.PUBLIC_MEMBER;

import java.util.Scanner;

/**
 * 题目：输入一行字符，分别统计出其中英文字母、空格、数字和其它字符的个数。
 * 程序分析：利用while语句,条件为输入的字符不为'\n'.
 */
public class Topic07_DifferCharStatics {
    public static final char MinChineseASCII = 0x4E00;
    public static final char MaxChineseASCII = 0x9FA5;
    public static final char MinCapitalCaseASCII = 0x0041;
    public static final char MaxCapitalCaseASCII = 0x005A;
    public static final char MinLowerCaseASCII = 0x0061;
    public static final char MaxLowerCaseASCII = 0x007A;

    public static void devideString(String str){
        int cn=0,en = 0,space = 0,number = 0,others = 0;
        for (char c : str.toCharArray()){
            if(
                (c >= MinLowerCaseASCII && c<MaxLowerCaseASCII) ||
                (c >= MinCapitalCaseASCII && c<=MaxCapitalCaseASCII)
            )
                en++;
            else if (Character.isDigit(c))
                number++;
            else if (Character.isSpaceChar(c))
                space++;
            else if(c >= MinChineseASCII && c <= MaxChineseASCII)
                cn++;
            else
                others++;
        }
        System.out.println("total:"+str.length());
        System.out.println("cn:"+cn);
        System.out.println("en:"+en);
        System.out.println("number:"+number);
        System.out.println("space:"+space);
        System.out.println("others:"+others);
    }

}
